package company.xiaomi;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Mi1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        String s = sc.nextLine();
        List<String> array = new ArrayList<>();
        int n = s.length();
        int index = 0;
        while (index < n) {
            StringBuilder sb = new StringBuilder();
            if (s.charAt(index) == ' ') {
                sb.append(" ");
                index++;
            } else {
                while (index < n && s.charAt(index) != ' ') {
                    sb.append(s.charAt(index));
                    index++;
                }
            }
            index++;
            array.add(sb.toString());
        }
        Loop:
        for (String str : array) {
            if (str.length() < 8 || str.length() > 120)
                list.add(1);
            else {
                boolean num = false;
                boolean upCase = false;
                boolean lowerCase = false;
                boolean symbol = false;
                int length = str.length();
                for (int i = 0; i < length; i++) {
                    if (num && upCase && lowerCase && symbol) {
                        list.add(0);
                        continue Loop;
                    }
                    char c = str.charAt(i);
                    if (c >= '0' && c <= '9')
                        num = true;
                    else if (c >= 'A' && c <= 'A')
                        upCase = true;
                    else if (c >= 'a' && c <= 'z')
                        lowerCase = true;
                    else
                        symbol = true;
                }
                list.add(2);
            }
        }
        for (Integer i : list)
            System.out.println(i);
    }
}
